{% extends 'layout.html' %}


{% block content %}
    {% load my_tags %}
    {% load rbac %}
    <div>
        {% if request|has_permission:'add_class' %}
            <a class="btn btn-primary" href="{% reverse_url request 'add_class' %}">添加</a>
        {% endif %}
    </div>

    <form action="" class="form-inline pull-right">
        <input type="text" name="query" class="form-control">
        <button class="btn btn-sm btn-primary">搜索</button>
    </form>

    <form action="" method="post" class="form-inline">
        {% csrf_token %}
        {#        <select name="action" id="" class="form-control">#}
        {##}
        {#        </select>#}
        {#        <button class="btn btn-primary btn-sm">提交</button>#}

        <table class="table table-bordered table-hover">
            <thead>
            <tr>
                <th>选择</th>
                <th>序号</th>
                <th>名称</th>
                <th>学费</th>
                <th>说明</th>
                <th>开班日期</th>
                <th>结业日期</th>
                <th>老师</th>
                <th>班级类型</th>
                {% if request|has_permission:'edit_class' %}
                    <th>操作</th>
                {% endif %}
            </tr>
            </thead>
            <tbody>

            {% for class_obj in all_class %}
                <tr>
                    <td><input type="checkbox" name="ids" value="{{ class_obj.pk }}"></td>
                    <td>{{ forloop.counter }}</td>
                    <td><a href="{% url 'course_record_list' class_obj.pk %}">{{ class_obj }}</a></td>
                    <td>{{ class_obj.price }}</td>
                    <td>{{ class_obj.memo }}</td>
                    <td>{{ class_obj.start_date }}</td>
                    <td>{{ class_obj.graduate_date }}</td>
                    <td>{{ class_obj.show_teachers }}</td>
                    <td>{{ class_obj.get_class_type_display }}</td>
                    {% if request|has_permission:'edit_class' %}

                        <td><a href="{% reverse_url request 'edit_class' class_obj.pk %}"> <i
                                class="fa fa-edit"></i></a>
                        </td>
                    {% endif %}
                </tr>
            {% endfor %}
            </tbody>
        </table>

    </form>

    <nav aria-label="Page navigation">
        <ul class="pagination">
            {{ page_html|safe }}
        </ul>
    </nav>

{% endblock %}